home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Demo's / Igor Demo Pro / 1 PutContentsIn Igor Pro Folder / WaveMetrics Procedures / Analysis / DSP (Fourier etc) / DSP Window Functions < prev    next >
Text File  |  1994-02-18  |  2KB  |  112 lines

  1.  
  2. |******** several window functions...
  3. |    each returns the average sum square value
  4. |    this is needed for psd normalization 
  5. |    Note: These functions do not need to be double precision unless you have
  6. |        very unusual data that exceeds the dynamic range of single precision.
  7. |        If that is the case (data > 10^35 or data < 10^-35) you will have to
  8. |        generate your own versions that are double precision.
  9. |********
  10.  
  11.  
  12. Function ParzenOrWelch(w,isWelch)
  13.     wave w
  14.     variable isWelch
  15.     
  16.     variable N=numpnts(w),tmp
  17.  
  18.     variable sumsqr=0,jj=0
  19.     do
  20.         tmp= (jj-0.5*(N-1))/(0.5*(N+1))
  21.         if(isWelch)
  22.             tmp= 1 - tmp^2
  23.         else
  24.             tmp= 1-abs(tmp)
  25.         endif
  26.         sumsqr += tmp^2
  27.         w[jj] *= tmp
  28.         jj+=1
  29.     while(jj<N)
  30.     return sumsqr/N
  31. end
  32.  
  33. Function Parzen(w)
  34.     wave w
  35.  
  36.     return ParzenOrWelch(w,0)
  37. End
  38.  
  39. Function Welch(w)
  40.     wave w
  41.  
  42.     return ParzenOrWelch(w,1)
  43. End
  44.  
  45. Function Kaiser(w,beta)    | see D.F. Elliott, Handbook of Digital SIgnal Processing, Academic Press, P 68
  46.     wave w
  47.     variable beta
  48.     
  49.     variable N=numpnts(w),tmp
  50.     variable IBeta= BessI(0,beta), NM1= (N-1)/2
  51.  
  52.     variable sumsqr=0,jj=0
  53.     do
  54.         tmp= BessI(0,beta*sqrt(1 - ( (jj-NM1)/NM1 )^2))/IBeta
  55.         sumsqr += tmp^2
  56.         w[jj] *= tmp
  57.         jj+=1
  58.     while(jj<N)
  59.     return sumsqr/N
  60. end
  61.  
  62.  
  63. Function Hamming(w)
  64.     wave w
  65.     
  66.     variable N=numpnts(w),tmp
  67.     variable omega= 2*Pi/N,mid= (N-1)/2
  68.  
  69.     variable sumsqr=0,i=0
  70.     do
  71.         tmp= 0.54 + 0.46*cos(omega*(i-mid))
  72.         sumsqr += tmp^2
  73.         w[i] *= tmp
  74.         i+=1
  75.     while(i<N)
  76.     return sumsqr/N
  77. end
  78.  
  79. Function BlackmanHarris3(w)
  80.     wave w
  81.     
  82.     variable N=numpnts(w),tmp
  83.     variable omega= 2*Pi/N,mid= (N-1)/2
  84.  
  85.     variable sumsqr=0,i=0
  86.     do
  87.         tmp= 0.42323 + 0.49755*cos(omega*(i-mid)) +  0.07922*cos(omega*2*(i-mid))
  88.         sumsqr += tmp^2
  89.         w[i] *= tmp
  90.         i+=1
  91.     while(i<N)
  92.     return sumsqr/N
  93. end
  94.  
  95. Function KaiserBessel(w)
  96.     wave w
  97.     
  98.     variable N=numpnts(w),tmp
  99.     variable omega= 2*Pi/N,mid= (N-1)/2
  100.  
  101.     variable sumsqr=0,i=0
  102.     do
  103.         tmp= 0.40243 + 0.49804*cos(omega*(i-mid)) 
  104.         tmp += 0.09831*cos(omega*2*(i-mid)) +  0.00122*cos(omega*3*(i-mid))
  105.         sumsqr += tmp^2
  106.         w[i] *= tmp
  107.         i+=1
  108.     while(i<N)
  109.     return sumsqr/N
  110. end
  111.  
  112.